/*---------------------------------------------------------------------------------

	Printing on both screens with a keyboard

---------------------------------------------------------------------------------*/
#include <nds.h>
#include <stdio.h>

PrintConsole pcMain;
PrintConsole pcSub;

void keyUp(int c)
{
	consoleSelect(&pcSub);
	iprintf("%c", c);
}

//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
	
	videoSetMode(MODE_0_2D);
	videoSetModeSub(MODE_0_2D);
	vramSetBankA(VRAM_A_MAIN_BG);
	vramSetBankC(VRAM_C_SUB_BG);

	//two print consoles
	consoleInit(&pcMain,0,BgType_Text4bpp, BgSize_T_256x256, 2,0,true,true);
	consoleInit(&pcSub,0,BgType_Text4bpp, BgSize_T_256x256, 2,0,false,true);
	
	//create a window for the sub display so it stays above the keyboard.
	consoleSetWindow(&pcSub, 0,0,32,8);

	//set up our keyboard.  I used mtheal's vram tool to figure out where to put everything
	Keyboard* kb = keyboardInit(0,1,BgType_Text4bpp, BgSize_T_256x256, 3,1,false,true);

	kb->OnKeyReleased = keyUp;

	keyboardShow();

	//prove the top screen works
	consoleSelect(&pcMain);
	iprintf("hello cruel world....");

	while(1) {

		keyboardUpdate();

		swiWaitForVBlank();
	}

}
